Method: Symbol#<=>
- Defined in:
- string.c
#<=>(object) ⇒ -1, ...
If object
is a symbol, returns the equivalent of symbol.to_s <=> object.to_s
:
:bar <=> :foo # => -1
:foo <=> :foo # => 0
:foo <=> :bar # => 1
Otherwise, returns nil
:
:foo <=> 'bar' # => nil
Related: String#<=>.
12204 12205 12206 12207 12208 12209 12210 12211 |
# File 'string.c', line 12204
static VALUE
sym_cmp(VALUE sym, VALUE other)
{
if (!SYMBOL_P(other)) {
return Qnil;
}
return rb_str_cmp_m(rb_sym2str(sym), rb_sym2str(other));
}
|